﻿using Adp;
using Microsoft.AspNetCore.Mvc;
using Yqd.Models;
using System.Linq;
using Adp.Common;
using System;
using Yqd.Core;
using Yqd.Enm;
using Yqd.Controllers.Filter;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;

namespace Yqd.Controllers
{
    [Area("Yqd")]
    public class WxSuperviseController : Controller
    {
        YqdContext ctx;
        DdService ddService;
        public WxSuperviseController(YqdContext ctx, DdService ddService)
        {
            this.ctx = ctx;
            this.ddService = ddService;
        }

       [User]
        public ActionResult GetList()
        {
            var TaskID = Form.GetLong("TaskID");
            var SuperviseID = Form.GetInt("SuperviseID");
            var CoordinateID = Form.GetInt("CoordinateID");
            var page = Form.GetInt("page", 1);
            var pagesize = Form.GetInt("pagesize", 0);
            var data = new List<dynamic>();
            var user = ctx.Yqd_User.Select(it => new { it.EmployeeCode, it.Name }).ToList();
            var r = ctx.Yqd_Supervise.Where(it => it.TaskID == TaskID && it.SuperviseType == 督导类型.督导);
            data.AddRange(r.ToList().Select(it => new
            {
                it.TaskID,
                it.SuperviseID,
                CoordinateID = 0,
                CooperativeID = 0,
                ItemID = it.SuperviseID,
                ItemType = 事项类型.钉办督导,
                Principal = user.FirstOrDefault(m => m.EmployeeCode == it.EmployeeCode)?.Name,
                it.Status,
                it.Content,
                it.Instime
            }));
            data.AddRange(ctx.Yqd_Coordinate.Where(it => it.TaskID == TaskID).ToList().Select(it => new
            {
                it.TaskID,
                SuperviseID = 0,
                it.CoordinateID,
                it.CooperativeID,
                ItemID = it.CoordinateID,
                ItemType = 事项类型.申请协调,
                it.Status,
                Principal = user.FirstOrDefault(m => m.EmployeeCode == it.Coordinator)?.Name,
                Content = it.Item,
                it.Instime
            }));
            if (SuperviseID > 0) data = data.Where(it => it.SuperviseID == SuperviseID).ToList();
            if (CoordinateID > 0) data = data.Where(it => it.CoordinateID == CoordinateID).ToList();
            data = data.OrderBy(it => it.ItemType).OrderByDescending(it => it.Instime).ToList();
            var totalcount = r.Count();
            if (pagesize > 0)
            {
                r = r.Skip((page - 1) * pagesize).Take(pagesize);
            }
            var assign = ctx.Yqd_Assign.Where(it=>it.TaskID == TaskID && (it.ItemType ==  事项类型.钉办督导 || it.ItemType == 事项类型.申请协调)).ToList();
            var l = WxUser.LogonInfo;
            var DeptRole = l.Role.Any(it => it == 角色类型.管理员 || it == 角色类型.部门联络员);
            var MsRole = l.Role.Any(it=> it == 角色类型.管理员 || it == 角色类型.市领导 || it == 角色类型.领导秘书);
            var platform = Form.GetInt("platform", 1);
            if (DeptRole && platform == 2)
            {
                assign = assign.Where(it => it.LeadUnit == l.UnitCode).ToList();
            }
            var plan = ctx.Yqd_JobPlan.Where(it => it.CheckStatus != 审核状态.退回 && (it.ItemType == 事项类型.钉办督导 || it.ItemType == 事项类型.申请协调)).ToList();
            var bplan = ctx.Yqd_JobPlan.Where(it => it.CheckStatus == 审核状态.退回 && (it.ItemType == 事项类型.钉办督导 || it.ItemType == 事项类型.申请协调)).ToList();
            var progress = ctx.Yqd_PlanProgress.Where(it => it.CheckStatus != 审核状态.退回 && (it.ItemType == 事项类型.钉办督导 || it.ItemType == 事项类型.申请协调)).ToList();
            var bprogress = ctx.Yqd_PlanProgress.Where(it => it.CheckStatus == 审核状态.退回 && (it.ItemType == 事项类型.钉办督导 || it.ItemType == 事项类型.申请协调)).ToList();
            var dept = ctx.Yqd_Unit.Select(it => new { it.UnitCode, it.Name }).ToList();
            var task = ctx.Yqd_Task.FirstOrDefault(it => it.TaskID == TaskID);
            var cIDs = data.Select(it => it.CooperativeID).ToArray();
            var cooperative = ctx.Yqd_Cooperative.Where(it => cIDs.Contains(it.CooperativeID)).Select(it=>new {it.CooperativeID, it.CooperativeUnit }).ToList();
            return this.ToJson(new
            {
                success = true,
                totalcount,
                DeptRole,
                MsRole,
                task.TaskName,
                task.LeaderUnitCode,
                data = data.Select(it => new
                {
                    it.SuperviseID,
                    it.CoordinateID,
                    Content = it.Content ?? "",
                    Instime = it.Instime.ToString("yyyy年M月d日"),
                    Status = it.Status.ToString(),
                    it.Principal,
                    cooperative.FirstOrDefault(d => d.CooperativeID == it.CooperativeID)?.CooperativeUnit,
                    Tag = it.ItemType.ToString(),
                    AssignLimit = it.Instime.AddDays(7).ToString("yyyy-MM-dd"),
                    ShowAssign = !assign.Any(s => s.ItemID == it.ItemID && s.ItemType == it.ItemType) || !plan.Any(m => m.ItemID == it.ItemID && m.ItemType == it.ItemType),
                    Assign = assign.Where(s => s.ItemID == it.ItemID && s.ItemType == it.ItemType).Select(n => new
                    {
                        n.AssignID,
                        Item = n.Item ?? "",
                        n.LeadUnit,
                        ShowHistory = bplan.Any(b => b.AssignID == n.AssignID),
                        Dept = dept.FirstOrDefault(d => d.UnitCode == n.LeadUnit)?.Name,
                        AssignLimit = n.AssignLimit.ToString("yyyy.MM.dd"),
                        AssignTime = n.Instime.ToString("yyyy.MM.dd"),
                        AssignMan = user.FirstOrDefault(m => m.EmployeeCode == n.EmployeeCode)?.Name,
                        IsCheck = plan.Any(m => m.AssignID == n.AssignID && m.CheckStatus == Enm.审核状态.待审),
                        IsChecked = plan.Any(m => m.AssignID == n.AssignID && m.CheckStatus == Enm.审核状态.同意),
                        ShowAgree = progress.Any(b => b.AssignID == n.AssignID && b.CheckStatus == 审核状态.待审),
                        Plan = plan.Where(m => m.AssignID == n.AssignID).ToList().Select(s => new
                        {
                            s.PlanID,
                            Measure = s.Measure ?? "",
                            s.Leader,
                            s.Linkman,
                            ShowHistory = bprogress.Any(b => b.PlanID == s.PlanID),
                            IsChecked = s.CheckStatus == Enm.审核状态.同意,
                            Status = Enum.GetName(typeof(Enm.任务计划完成状态), s.Status),
                            PlanCompleteTime = s.PlanCompleteTime != null ? s.PlanCompleteTime.ToString("yyyy.MM.dd") : "",
                            Progress = progress.Where(b => b.PlanID == s.PlanID).OrderByDescending(c => c.Instime).ToList().Select(m => new
                            {
                                m.ProgressID,
                                IsCheck = m.CheckStatus == Enm.审核状态.待审,
                                IsDeal = m.PlanStatus == Enm.任务计划办理情况.申请延期,
                                PlanStatus = m.PlanStatus == 0 ? "" : m.PlanStatus.ToString(),
                                PlanResult = m.PlanResult ?? "",
                                DelayReason = m.DelayReason ?? "",
                                DelayTime = m.DelayTime != null ? m.DelayTime.ToString("yyyy.MM.dd") : ""
                            })
                        })
                    })
                })
            });
        }

        [User]
        public ActionResult GetUnSuperviseList()
        {
            var flag = Form.GetInt("flag", 1);
            if (flag > 4) flag = 4;
            var page = Form.GetInt("page", 1);
            var pagesize = Form.GetInt("pagesize", 0);
            var l = WxUser.LogonInfo;
            var data = new List<dynamic>();
            var tIDs = new List<long>();
            var assign = ctx.Yqd_Assign.Where(it => it.LeadUnit == l.UnitCode).Select(it => new { it.TaskID, it.ItemID, it.ItemType, it.AssignLimit }).ToList();
            tIDs.AddRange(assign.Select(it => it.TaskID));
            var supervise = ctx.Yqd_Supervise.Select(it => new { it.TaskID, it.SuperviseID, it.Content, it.Status, it.Instime }).ToList();
            var esupervise = ctx.Yqd_ExactSupervise.Select(it => new { it.TaskID, it.SuperviseID, it.GUID, it.Problem, it.Status, it.Instime }).ToList();
            var ssupervise = ctx.Yqd_SpecialSupervise.ToList();
            var coordinate = ctx.Yqd_Coordinate.Select(it => new { it.TaskID, it.CoordinateID, it.Item, it.Status, it.Instime }).ToList();
            var cooperative = ctx.Yqd_Cooperative.Where(it => it.CooperativeUnit == l.UnitCode).Select(it => new { it.TaskID, it.CooperativeID, it.CooperativeResult, it.Item, it.RespondTime, it.Instime }).ToList();
            tIDs.AddRange(cooperative.Select(it => it.TaskID));
            var tasks = ctx.Yqd_Task.Where(it => tIDs.Contains(it.TaskID)).Select(it => new { it.TaskID, it.TaskName, it.LeaderUnitName, it.CreateTime, it.FAreaCode, it.TaskStatus }).ToList();
            var nt = DateTime.Now.Date;
            switch (flag)
            {
                case 0:
                case 1:
                    var sIDs = assign.Where(it => it.ItemType == 事项类型.钉办督导).Select(it => it.ItemID).Distinct().ToArray();
                    supervise = supervise.Where(it => sIDs.Contains(it.SuperviseID) && it.Status == 办理情况.已滞后).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.申请协调).Select(it => it.ItemID).Distinct().ToArray();
                    coordinate = coordinate.Where(it => sIDs.Contains(it.CoordinateID) && it.Status == 办理情况.已滞后).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.精准督查).Select(it => it.ItemID).Distinct().ToArray();
                    esupervise = esupervise.Where(it => sIDs.Contains(it.SuperviseID) && it.Status == 办理情况.已滞后).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.专项督查).Select(it => it.ItemID).Distinct().ToArray();
                    ssupervise = ssupervise.Where(it => sIDs.Contains(it.SuperviseID) && it.Status == 办理情况.已滞后).ToList();
                    cooperative = cooperative.Where(it => nt > it.RespondTime && it.CooperativeResult == 协同结果.未反馈).ToList();
                    break;
                case 2:
                    sIDs = assign.Where(it => it.ItemType == 事项类型.钉办督导 && it.AssignLimit.Subtract(nt).Days <= 7).Select(it => it.ItemID).Distinct().ToArray();
                    supervise = supervise.Where(it => sIDs.Contains(it.SuperviseID) && (it.Status == 办理情况.未回复 || it.Status == 办理情况.已回复)).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.申请协调 && it.AssignLimit.Subtract(nt).Days <= 7).Select(it => it.ItemID).Distinct().ToArray();
                    coordinate = coordinate.Where(it => sIDs.Contains(it.CoordinateID) && (it.Status == 办理情况.未回复 || it.Status == 办理情况.已回复)).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.精准督查 && it.AssignLimit.Subtract(nt).Days <= 7).Select(it => it.ItemID).Distinct().ToArray();
                    esupervise = esupervise.Where(it => sIDs.Contains(it.SuperviseID) && (it.Status == 办理情况.未回复 || it.Status == 办理情况.已回复)).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.专项督查 && it.AssignLimit.Subtract(nt).Days <= 7).Select(it => it.ItemID).Distinct().ToArray();
                    ssupervise = ssupervise.Where(it => sIDs.Contains(it.SuperviseID) && (it.Status == 办理情况.未回复 || it.Status == 办理情况.已回复)).ToList();
                    cooperative = cooperative.Where(it => it.RespondTime.Subtract(nt).Days <= 7 && it.CooperativeResult == 协同结果.未反馈).ToList();
                    break;
                case 3:
                    sIDs = assign.Where(it => it.ItemType == 事项类型.钉办督导 && it.AssignLimit.Subtract(nt).Days > 7).Select(it => it.ItemID).Distinct().ToArray();
                    supervise = supervise.Where(it => sIDs.Contains(it.SuperviseID) && (it.Status == 办理情况.未回复 || it.Status == 办理情况.已回复)).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.申请协调 && it.AssignLimit.Subtract(nt).Days > 7).Select(it => it.ItemID).Distinct().ToArray();
                    coordinate = coordinate.Where(it => sIDs.Contains(it.CoordinateID) && (it.Status == 办理情况.未回复 || it.Status == 办理情况.已回复)).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.精准督查 && it.AssignLimit.Subtract(nt).Days > 7).Select(it => it.ItemID).Distinct().ToArray();
                    esupervise = esupervise.Where(it => sIDs.Contains(it.SuperviseID) && (it.Status == 办理情况.未回复 || it.Status == 办理情况.已回复)).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.专项督查 && it.AssignLimit.Subtract(nt).Days > 7).Select(it => it.ItemID).Distinct().ToArray();
                    ssupervise = ssupervise.Where(it => sIDs.Contains(it.SuperviseID) && (it.Status == 办理情况.未回复 || it.Status == 办理情况.已回复)).ToList();
                    cooperative = cooperative.Where(it => it.RespondTime.Subtract(nt).Days > 7 && it.CooperativeResult == 协同结果.未反馈).ToList();
                    break;
                case 4:
                    sIDs = assign.Where(it => it.ItemType == 事项类型.钉办督导).Select(it => it.ItemID).Distinct().ToArray();
                    supervise = supervise.Where(it => sIDs.Contains(it.SuperviseID) && it.Status == 办理情况.已完结).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.申请协调).Select(it => it.ItemID).Distinct().ToArray();
                    coordinate = coordinate.Where(it => sIDs.Contains(it.CoordinateID) && it.Status == 办理情况.已完结).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.精准督查).Select(it => it.ItemID).Distinct().ToArray();
                    esupervise = esupervise.Where(it => sIDs.Contains(it.SuperviseID) && it.Status == 办理情况.已完结).ToList();
                    sIDs = assign.Where(it => it.ItemType == 事项类型.专项督查).Select(it => it.ItemID).Distinct().ToArray();
                    ssupervise = ssupervise.Where(it => sIDs.Contains(it.SuperviseID) && it.Status == 办理情况.已完结).ToList();
                    cooperative = cooperative.Where(it => it.CooperativeResult != 协同结果.未反馈).ToList();
                    break;
            }
            dynamic t = null;
            if (supervise.Count > 0)
                data.AddRange(supervise.Select(it => new
                {
                    TaskID = it.TaskID.ToString(),
                    it.SuperviseID,
                    CooperativeID = 0,
                    CoordinateID = 0,
                    ExactSuperviseID = 0,
                    SpecialsSuperviseID = 0,
                    (t = tasks.FirstOrDefault(n => n.TaskID == it.TaskID))?.TaskName,
                    t.LeaderUnitName,
                    TaskStatus = Enum.GetName(typeof(任务状态), t.TaskStatus),
                    CreateTime = t.CreateTime.ToString("yyyy.MM.dd"),
                    Content = it.Content ?? "",
                    Status = Enum.GetName(typeof(办理情况), it.Status),
                    AssignLimit = assign.FirstOrDefault(n => n.ItemID == it.SuperviseID && n.ItemType == 事项类型.钉办督导)?.AssignLimit.ToString("yyyy.MM.dd"),
                    Tag = "督导",
                    it.Instime
                }));
            t = null;
            if (coordinate.Count() > 0)
                data.AddRange(coordinate.Select(it => new
                {
                    TaskID = it.TaskID.ToString(),
                    SuperviseID = 0,
                    CooperativeID = 0,
                    SpecialsSuperviseID = 0,
                    ExactSuperviseID = 0,
                    it.CoordinateID,
                    (t = tasks.FirstOrDefault(n => n.TaskID == it.TaskID))?.TaskName,
                    t.LeaderUnitName,
                    TaskStatus = Enum.GetName(typeof(任务状态), t.TaskStatus),
                    CreateTime = t.CreateTime.ToString("yyyy.MM.dd"),
                    Content = it.Item ?? "",
                    Status = Enum.GetName(typeof(办理情况), it.Status),
                    AssignLimit = assign.FirstOrDefault(n => n.ItemID == it.CoordinateID && n.ItemType == 事项类型.申请协调)?.AssignLimit.ToString("yyyy.MM.dd"),
                    Tag = "协调",
                    it.Instime
                }));
            t = null;
            if (cooperative.Count() > 0)
                data.AddRange(cooperative.Select(it => new
                {
                    TaskID = it.TaskID.ToString(),
                    SuperviseID = 0,
                    it.CooperativeID,
                    CoordinateID = 0,
                    SpecialsSuperviseID = 0,
                    ExactSuperviseID = 0,
                    (t = tasks.FirstOrDefault(n => n.TaskID == it.TaskID))?.TaskName,
                    t.LeaderUnitName,
                    TaskStatus = Enum.GetName(typeof(任务状态), t.TaskStatus),
                    Status = Enum.GetName(typeof(协同结果), it.CooperativeResult),
                    CreateTime = t.CreateTime.ToString("yyyy.MM.dd"),
                    Content = it.Item ?? "",
                    AssignLimit = it.RespondTime.ToString("yyyy.MM.dd"),
                    Tag = "协同",
                    it.Instime
                }));
            if (esupervise.Count() > 0)
            {
                var ids = esupervise.Select(it => it.GUID).Distinct().ToArray();
                var pv = ctx.Yqd_ExactSupervise.Where(it => ids.Contains(it.GUID)).ToList();
                foreach (var id in ids)
                {
                    if (flag == 4 && pv.Any(it=>it.GUID == id && it.Status!= 办理情况.已完结))
                    {
                        continue;
                    }
                    var es = pv.Where(it => it.GUID == id);
                    var problem = "";
                    var i = 1;
                    dynamic o = null;
                    var Status = 办理情况.已完结;
                    var bl = false;
                    if (es.Any(it=>it.Status == 办理情况.未回复 || it.Status == 办理情况.已滞后))  {
                        Status = 办理情况.未回复;
                        bl = true;
                    }
                    if (es.Any(it => it.Status == 办理情况.已滞后))
                    {
                        Status = 办理情况.已滞后;
                        bl = true;
                    }
                    foreach (var e in es)
                    {
                        problem += i + "、" + e.Problem + "  ";
                        if (o == null)
                        {
                            if (bl && e.Status == 办理情况.已完结) continue;
                            var AssignLimit = assign.FirstOrDefault(n => n.ItemID == e.SuperviseID && n.ItemType == 事项类型.精准督查)?.AssignLimit.ToString("yyyy.MM.dd");
                            o = new
                            {
                                e.TaskID,
                                e.SuperviseID,
                                e.Instime,
                                AssignLimit
                            };
                        }
                        i++;
                    }
                    if (o == null) continue;
                    t = tasks.FirstOrDefault(n => n.TaskID == o.TaskID);
                    data.Add(new
                    {
                        TaskID = o.TaskID.ToString(),
                        SuperviseID = 0,
                        CooperativeID = 0,
                        CoordinateID = 0,
                        SpecialsSuperviseID = 0,
                        ExactSuperviseID = o.SuperviseID,
                        t.TaskName,
                        t.LeaderUnitName,
                        TaskStatus = Enum.GetName(typeof(任务状态), t.TaskStatus),
                        CreateTime = t.CreateTime.ToString("yyyy.MM.dd"),
                        Content = problem,
                        GUID = id,
                        Status = Status.ToString(),
                        o.AssignLimit,
                        Tag = "精准督查",
                        o.Instime
                    });
                }
            }
            if (ssupervise.Count() > 0)
            {
                var template = ctx.Yqd_SpecialTemplate.FirstOrDefault(it => it.Name == "督查对象");
                var fieldid = "";
                if (template != null) fieldid = template.FieldID;
                var ids = ssupervise.Select(it => it.TargetID).ToArray();
                var targets = ctx.Yqd_SpecialTarget.Where(it => ids.Contains(it.TargetID)).Select(it => new { it.TargetID, it.Content }).ToList();
                var dept = ctx.Yqd_Unit.Select(it => new { it.UnitCode, it.Name }).ToList();
                foreach (var s in ssupervise)
                {
                    var ts = targets.FirstOrDefault(it => it.TargetID == s.TargetID);
                    if (ts != null && ts.Content.HasValue())
                    {
                        var o = JObject.Parse(ts.Content);
                        var Target = "";
                        if (fieldid != "")
                        {
                            Target = o[fieldid].ToString();
                        }
                        data.Add(new
                        {
                            s.TaskID,
                            SuperviseID = 0,
                            CooperativeID = 0,
                            CoordinateID = 0,
                            ExactSuperviseID = 0,
                            SpecialsSuperviseID = s.SuperviseID,
                            CheckUnit = dept.FirstOrDefault(it => it.UnitCode == s.CheckUnit)?.Name,
                            s.Checker,
                            CheckInstime = s.CheckInstime.ToString("yyyy.MM.dd"),
                            Content = s.Problem,
                            Status = Enum.GetName(typeof(办理情况), s.Status),
                            AssignLimit = assign.FirstOrDefault(n => n.ItemID == s.SuperviseID)?.AssignLimit.ToString("yyyy.MM.dd"),
                            Tag = "专项督查",
                            s.Instime
                        });
                    }
                }
            }
            data = data.OrderByDescending(it => it.Instime).ToList();
            var totalcount = data.Count();
            if (pagesize > 0)
            {
                data = data.Skip((page - 1) * pagesize).Take(pagesize).ToList();
            }
            else
            {
                data = data.Take(2).ToList();
            }
            return this.ToJson(new
            {
                success = true,
                totalcount,
                data 
            });
        }

        [User]
        public IActionResult Add(Yqd_Supervise model)
        {
            var bl = model.SuperviseType == 督导类型.钉办;
            var fl = bl;
            if (!bl && string.IsNullOrWhiteSpace(model.Content))
            {
                ModelState.AddModelError("Content", "请填写督导意见");
            }
            if (!ModelState.IsValid)
            {
                return this.ToJson(new
                {
                    success = false,
                    stateMsg = from sk in ModelState.AsEnumerable()
                               where sk.Value.Errors.Count() > 0
                               select new { id = sk.Key, msg = sk.Value.Errors.FirstOrDefault().ErrorMessage }
                });
            }
            if(bl)
            {
                var m = ctx.Yqd_Supervise.FirstOrDefault(it => it.TaskID == model.TaskID && it.SuperviseType == Enm.督导类型.钉办);
                if (m == null) bl = false;
                else model = m;
            }
            model.Status = 办理情况.待交办;
            model.Instime = DateTime.Now;
            model.EmployeeCode = WxUser.LogonInfo.EmployeeCode;
            model.UnitCode = WxUser.LogonInfo.UnitCode;
            if (!bl) ctx.Yqd_Supervise.Add(model);
            var ret = ctx.SaveChanges();
            if (ret > 0)
            {
                if (fl)
                {
                    var task = ctx.Yqd_Task.FirstOrDefault(it => it.TaskID == model.TaskID);
                    if (task != null)
                    {
                        var msg = ddService.Notification(task.LeaderUnitCode, "领导钉办", task.TaskName, "领导要求您们加紧时间办理！\n");
                        Logs.Warning<WxMySuperviseController>(WxUser.LogonInfo.Name + "发了工作通知，返回值：" + msg);
                    }
                }
                TaskLogService.AddLog(model.TaskID, fl ? "要求钉办" : "提出了督导意见");
            }
            return this.ToJson(new
            {
                success = true,
                ret
            });
        }

        [User]
        public ActionResult Delete()
        {
            var SuperviseID = Form.GetInt("SuperviseID");
            var ret = ctx.Database.ExecuteSql("delete from Yqd_Supervise where SuperviseID={0}", SuperviseID);
            return this.ToJson(new
            {
                success = true,
                ret
            });
        }
    }
}
